<template>
  <div>
    <h2>登陆页面</h2>
    用户名<input type="text" v-model="username">
    密码<input type="text" v-model="password">
    <button @click="sub">登录</button>
  </div>
</template>

<script>
export default {
  data(){
    return{
      username:'',
      password:''
    }
  },
  methods:{
    sub:function(){
           let data={
        username:this.username,
        password:this.password
      };
      this.axios({
        url:'http://127.0.0.1:8000/app01/login/',
        method:'post',
        data:data
      }).then(res=>{
        if(res.data.code==1000){
          // 1.存数据
          localStorage.setItem('uid',res.data.data);

          // 2.跳转
          this.$router.push('/List/')
        }else{
          alert(res.data.msg);
        }
      })
    }
  }
}
</script>

<style>

</style>
